package com.erp.myAdapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.erp.R;
import com.erp.util.Myutil;

import java.util.List;

/**
 * Created by Administrator on 2016/11/17/017.
 * 作者：刘洋
 */
public class GaugeivGvAdapter extends BaseAdapter {
    private List<String> mlistimg;
    private Context mcontext;
    private LayoutInflater minflater;
    private int mwidth;
    private String msession_name;
    public GaugeivGvAdapter(List<String> listimg,Context context,int width,String session_name){
        super();
        this.mlistimg=listimg;
        this.mcontext=context;
        this.mwidth=width;
        this.msession_name=session_name;
        this.minflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return mlistimg.size();
    }

    @Override
    public Object getItem(int i) {
        return mlistimg.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        final ViewHolder vh;
        if(view==null) {
            vh=new ViewHolder();
            view = minflater.inflate(R.layout.lv_iv_item, null);
            vh.iv = (ImageView) view.findViewById(R.id.iv_item);
            view.setTag(vh);
        }else{
            vh= (ViewHolder) view.getTag();
        }
        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams)  vh.iv.getLayoutParams();
        // 取控件aaa当前的布局参数
        linearParams.height = (int) (mwidth/3); // 当控件的高强制设成365象素
        vh.iv.setLayoutParams(linearParams); // 使设置好的布局参数应用到控件aaa
        Myutil.showhttpphoto(mlistimg.get(i),vh.iv,mcontext);
        return view;
    }
    public void Allnotify(List<String> list){
        mlistimg=list;
        notifyDataSetChanged();
    }
    private class ViewHolder{
        ImageView iv;
    }
}
